package tianwu.pic;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.net.Socket;
import android.graphics.*;

import javax.imageio.ImageIO;

public class SocketThread extends Thread {
	
	private Socket socket;
	private UI ui;
	private DataInputStream dis;
	private int width;
	private int heigth;
	private int length;
	private byte[] data;
	private ByteArrayOutputStream bos;
	
	public SocketThread(UI ui,Socket socket){
		this.socket = socket;
		this.ui = ui;
		try {
			this.dis = new DataInputStream(socket.getInputStream());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public void run(){
		try {
			while(true){	
				//dis.read
				bos = new ByteArrayOutputStream();
				ui.drawNewImage(ImageIO.read(new ByteArrayInputStream(bos.toByteArray())));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
